package Combat5;

import org.omg.CosNaming.*;
import org.omg.PortableServer.Servant;

import DomainObject.BanqueDossiersImpl;
import DomainObject.BanqueInfractionsImpl;
//create by martin souliere
public class Server {
	public static org.omg.PortableServer.POA _poa;
	public static void main(String[] args) {
		// Initialize ORB
		org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
		
		try {
			org.omg.PortableServer.Servant servantBanqueInfractions;
			org.omg.PortableServer.Servant servantBanqueDossiers;
			org.omg.CORBA.Object oBanqueInfractions;
			org.omg.CORBA.Object oBanqueDossiers;

			// Initialize POA
			_poa = org.omg.PortableServer.POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
			_poa.the_POAManager().activate();
			
			// Initialize servant (Remote Object), convert to CORBA reference
			oBanqueInfractions = _poa.servant_to_reference((Servant)new BanqueInfractionsImpl());
			oBanqueDossiers = _poa.servant_to_reference(new BanqueDossiersImpl());

			// Register Rermote Object with naming context
			NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService"));
			NameComponent[] nameBanqueInfractions = new NameComponent[] { new NameComponent("BanqueInfractions", "service") };
			NameComponent[] nameBanqueDossiers = new NameComponent[] { new NameComponent("BanqueDossiers", "service") };
			nc.rebind(nameBanqueInfractions, oBanqueInfractions);
			nc.rebind(nameBanqueDossiers, oBanqueDossiers);
		} catch (Exception e) {
			e.printStackTrace();
		}
		// Start the ORB main thread
		orb.run();
	}
}
